home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / JAVA Utilities / JProxy 1.1.0 / customers / PURCHASE.JSP < prev    next >
Encoding:
Text File  |  2003-04-29  |  5.8 KB  |  181 lines

  1. <%@ page language="java" import="
  2.     java.util.*,
  3.     com.jproxy.site.mbeans.*,
  4.     com.jproxy.site.mbeans.config.*,
  5.     com.jproxy.site.ejbeans.interfaces.IPurchase,
  6.     com.jproxy.site.*"
  7.     errorPage="../error-page.jsp"
  8. %>
  9.  
  10. <jsp:useBean id="ses" scope="session" class="com.jproxy.site.JSPSession"/>
  11. <%
  12. if (!ses.isLoggedIn()) {
  13. %>
  14.   <jsp:forward page="login.jsp">
  15.   </jsp:forward>
  16. <%
  17. }
  18. ses.request(pageContext);
  19. %>
  20.  
  21. <%
  22.     String APPROVED = "1";
  23.     String DECLINED = "2";
  24.     String ERROR = "3";
  25.  
  26.     String customerID = ses.getParameter("customer-id");
  27.     String parentID = ses.getParameter("parent-id");
  28.     String x_response_code = request.getParameter("x_response_code");
  29.     if(x_response_code==null)
  30.         x_response_code = APPROVED;
  31.     String x_response_reason_code = request.getParameter("x_response_reason_code");
  32.     if(x_response_reason_code==null)
  33.         x_response_reason_code = APPROVED;
  34.     if(!(x_response_code.equals(APPROVED) && x_response_reason_code.equals(APPROVED)))
  35.     {
  36.         String x_response_reason_text = request.getParameter("x_response_reason_text");
  37.  
  38.         String descr = "[Purchase]: x_response_reason_text: "+x_response_reason_text+"\r\n";
  39.         String x_avs_code = request.getParameter("x_avs_code");
  40.         if(x_avs_code==null)
  41.             x_avs_code = "";
  42.         if(x_avs_code.indexOf("A")!=-1)
  43.             descr += "Address (Street) matches, ZIP does not \r\n";
  44.         if(x_avs_code.indexOf("E")!=-1)
  45.             descr += "AVS error \r\n";
  46.         if(x_avs_code.indexOf("N")!=-1)
  47.             descr += "No Match on Address (Street) or ZIP \r\n";
  48.         if(x_avs_code.indexOf("P")!=-1)
  49.             descr += "AVS not applicable for this transaction \r\n";
  50.         if(x_avs_code.indexOf("R")!=-1)
  51.             descr += "Retry. System unavailable or timed out \r\n";
  52.         if(x_avs_code.indexOf("S")!=-1)
  53.             descr += "Service not supported by issuer \r\n";
  54.         if(x_avs_code.indexOf("U")!=-1)
  55.             descr += "Address information is unavailable \r\n";
  56.         if(x_avs_code.indexOf("W")!=-1)
  57.             descr += "9 digit ZIP matches, Address (Street) does not \r\n";
  58.         if(x_avs_code.indexOf("X")!=-1)
  59.             descr += "Exact AVS Match \r\n";
  60.         if(x_avs_code.indexOf("Y")!=-1)
  61.             descr += "Address (Street) and 5 digit ZIP match \r\n";
  62.         if(x_avs_code.indexOf("Z")!=-1)
  63.             descr += "5 digit ZIP matches, Address (Street) does not \r\n";
  64.         System.out.println(descr);
  65.     %>
  66.   <jsp:forward page="buy.jsp">
  67.     <jsp:param name="error" value="<%=descr%>"/>
  68.   </jsp:forward>
  69.     <%
  70.     }
  71.     String customer_name = request.getParameter("x_first_name");
  72.         customer_name += " "+request.getParameter("x_last_name");
  73.     String phone = request.getParameter("x_phone");
  74.     String company = request.getParameter("x_company");
  75.     String address = request.getParameter("x_address");
  76.         address += " "+request.getParameter("x_city");
  77.         address += " "+request.getParameter("x_state");
  78.         address += " "+request.getParameter("x_zip");
  79.         address += " "+request.getParameter("x_country");
  80.     String email = request.getParameter("x_email");
  81.     String trans_id = request.getParameter("x_trans_id");
  82.     int number_of_licenses = 0;
  83.     double amount = 0;
  84.     String purchased_product = "";
  85.     int invoice = 15;
  86.     String discount_policy = "";
  87.  
  88.     try{
  89.         number_of_licenses = Integer.parseInt(request.getParameter("number_of_licenses"));
  90.     }catch(Exception ee){}
  91.     try{
  92.         amount = new Double(request.getParameter("x_amount")).doubleValue();
  93.     }catch(Exception ee){}
  94.  
  95.  
  96.     try{
  97.         invoice = Integer.parseInt(request.getParameter("x_invoice_num"));
  98.     }
  99.     catch(Exception e){
  100.     }
  101.  
  102.     ConfigMBean mbean = (ConfigMBean)JMXInvocator.getMBean(
  103.         "JProxy:service=JProxyConfigMBean", ConfigMBean.class);
  104.     mbean.edit("com.jproxy.commerce.invoice", ""+(invoice+1));
  105.  
  106. //    purchased_product = mbean.get("com.jproxy.proxy.name")+" "+mbean.get("com.jproxy.proxy.version");
  107. //    purchased_product = "JProxy Server 1.0";
  108.     purchased_product = ses.getParameter("productid");
  109.  
  110.     try
  111.     {
  112.         IPurchase pb = ses.session.createNewPurchase();
  113.         pb.setCommand(purchased_product);
  114.         pb.setAmount(amount);
  115.         pb.setNumberOfLicenses(number_of_licenses);
  116.         pb.setCustomerID(customerID);
  117.         pb.setCustomerName(customer_name);
  118.         pb.setCompany(company);
  119.         pb.setEMail(email);
  120.         pb.setAddress(address);
  121.         pb.setPhone(phone);
  122.         pb.setDiscountPolicy(discount_policy);
  123.         pb.setTransID(trans_id);
  124.         pb.setInvoiceNumber(invoice);
  125. /*
  126.         Properties p = new Properties();
  127.         p.put("purchased_product", purchased_product);
  128.         p.put("amount", ""+amount);
  129.         p.put("number_of_licenses", ""+number_of_licenses);
  130.         p.put("customer_id", ""+customerID);
  131.         p.put("customer_name", customer_name);
  132.         p.put("company", company);
  133.         p.put("email", email);
  134.         p.put("address", address);
  135.         p.put("phone", phone);
  136.         p.put("discount_policy", discount_policy);
  137.         p.put("trans_id", trans_id);
  138.         p.put("invoice", ""+invoice);
  139.         ses.setNewHit(ses.pc, "purchases", purchased_product, p);
  140. */
  141.     }catch(Exception ee){ee.printStackTrace();}
  142.  
  143. //    String file = "proxycomm.zip";
  144.     String forwardPage = "index.html";
  145.  
  146. //    EMailMe bean = new EMailMe();
  147. //    bean.request(request);
  148. //    bean.emailFile(email, purchased_product, file);
  149.     %>
  150.  
  151. <!-- HEADER -->
  152. <jsp:include page="../header.jsp" flush="true"/>
  153.  
  154. <!-- MAIN PANEL -->
  155.  
  156. <table border=0 width="100%">
  157.   <tr>
  158.     <td width="100%" valign="top">
  159.  
  160.       <div align="center">Thank you for shopping with us! Please allow of up to 12 hours for
  161.       the product(s) and the license keys to arrive in your mail box.
  162.       <p>
  163.       If you have any further questions please contact us at
  164.       <a class="h8VerdanaBold" href="mailto:<%=JSPRes.salesSupport%>"><%=JSPRes.salesSupport%></a>
  165.       </div>
  166.       <p>
  167.  
  168.       <p>customer_name: $<%=customer_name%></p>
  169.       <p>company: $<%=company%></p>
  170.       <p>address: $<%=address%></p>
  171.       <p>email: $<%=email%></p>
  172.       <p>phone: $<%=phone%></p>
  173.       <p>number_of_licenses: $<%=number_of_licenses%></p>
  174.       <p>amount: $<%=amount%></p>
  175.       <p>trans_id: $<%=trans_id%></p>
  176.     </td>
  177.   </tr>
  178. </table>
  179.  
  180. <jsp:include page="../footer.jsp" flush="true"/>
  181.